package main;

import static com.googlecode.javacv.cpp.opencv_core.cvPoint;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvDilate;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvErode;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvFindContours;

import com.googlecode.javacpp.Loader;
import com.googlecode.javacv.cpp.opencv_core.CvContour;
import com.googlecode.javacv.cpp.opencv_core.CvMemStorage;
import com.googlecode.javacv.cpp.opencv_core.CvSeq;
import com.googlecode.javacv.cpp.opencv_core.IplImage;

public class ImageProcessing {

	static CvSeq getContours(IplImage canniedImage, int contourHierarchy,
			int extractionMethod) {
		CvMemStorage mem = CvMemStorage.create();
		CvSeq contours = new CvSeq();
		cvFindContours(canniedImage, mem, contours,
				Loader.sizeof(CvContour.class), contourHierarchy,
				extractionMethod, cvPoint(0, 0));
		return contours;
	}

	static void nFoldClose(IplImage hueImage, int nFold) {
		cvDilate(hueImage, hueImage, null, nFold);
		cvErode(hueImage, hueImage, null, nFold);
	}

	static void nFoldOpen(IplImage hueImage, int nFold) {
		cvErode(hueImage, hueImage, null, nFold);
		cvDilate(hueImage, hueImage, null, nFold);
	}

}
